﻿using System;
using Combat;
using UnityEngine;

namespace UI
{
    public class WeaponSwitchUi : MonoBehaviour
    {
        [SerializeField] private WeaponSwitch weaponSwitch;
        [SerializeField] private UiFader[] weapons;

        private UiFader _fader;


        private void Awake()
        {
            _fader = GetComponent<UiFader>();
            
            weaponSwitch.WeaponUnlocked += WeaponSwitch_WeaponUnlocked;
        }

        private void WeaponSwitch_WeaponUnlocked(int index, Weapon _)
        {
            if (index == 1)
            {
                _fader.Show();
            }

            if (index > 1)
            {
                weapons[index].Show();
            }
        }
    }
}